import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ball_lion/resources/colours.dart';
import 'package:ball_lion/utils/utils.dart';

import 'wqs_text.dart';
import '../max_bottom_sheet.dart';

class QsBottomSheet extends StatelessWidget {
  final Widget child;
  final String? title;
  final dynamic closeResult;
  final bool scrollable;
  final String? backIcon;
  final TextStyle? titleStyle;
  final BoxConstraints? constraints;

  const QsBottomSheet(
      {super.key,
      required this.child,
      this.closeResult,
      this.title,
      this.scrollable = false,
      this.backIcon,
      this.titleStyle,
      this.constraints});

  @override
  Widget build(BuildContext context) {
    return MaxBottomSheet(
      enableDrag: false,
      clipBehavior: Clip.hardEdge,
      shape: const RoundedRectangleBorder(
          borderRadius: BorderRadius.only(
              topLeft: Radius.circular(10), topRight: Radius.circular(10))),
      onClosing: () {},
      constraints: constraints,
      builder: (context) {
        return SafeArea(
          child: Container(
            padding: const EdgeInsets.symmetric(horizontal: 16),
            color: Colors.white,
            child: Column(mainAxisSize: MainAxisSize.min, children: [
              Row(
                children: [
                  Container(
                    padding: const EdgeInsets.fromLTRB(0, 16, 0, 10),
                    alignment: Alignment.topLeft,
                    child: GestureDetector(
                      onTap: () {
                        Get.back(result: closeResult);
                      },
                      child: Image.asset(
                          Utils.getImgPath(backIcon ?? 'close.png'),
                          width: 24,
                          height: 24),
                    ),
                  ),
                  const Spacer(),
                  if (title != null)
                    QsText.style(title!,
                        style: titleStyle ??
                            const TextStyle(
                                fontSize: 16,
                                fontWeight: FontWeight.w500,
                                color: Colours.text)),
                  const Spacer(),
                  Container(
                    padding: const EdgeInsets.fromLTRB(0, 16, 0, 10),
                    alignment: Alignment.topLeft,
                    child: const SizedBox(width: 24),
                  ),
                ],
              ),
              child
            ]),
          ),
        );
      },
    );
  }
}
